package productidentification;

/**
 * @author Paula Chen (Javadoc), Ryan Cheatham (implementation)
 * 
 *         Entry of product identifier registry.
 * 
 */
public class ProductIDRegistryEntry implements Comparable<ProductIDRegistryEntry>
{
  private String className;
  private String name;
  private String description;

  /**
   * Constructs a new product identifier registry entry.
   * 
   * @param className
   *          the class name of the product identifier registry entry
   */
  public ProductIDRegistryEntry(String className)
  {
    this.className = className;
    name = null;
    description = null;
  }

  /**
   * Constructs a new product identifier registry entry.
   * 
   * @param className
   *          the class name of the product identifier registry entry
   * @param name
   *          the name of the product identifier registry entry
   * @param description
   *          the description of the product identifier registry entry
   */
  public ProductIDRegistryEntry(String className, String name, String description)
  {
    this.className = className;
    this.name = name;
    this.description = description;
  }

  /**
   * get the class name of the product identifier registry entry
   * 
   * @return the className of the product identifier registry entry
   */
  public String getClassName()
  {
    return className;
  }

  /**
   * get the name of the product identifier registry entry
   * 
   * @return the name of the product identifier registry entry
   */
  public String getName()
  {
    return name;
  }

  /**
   * get the description of the product identifier registry entry
   * 
   * @return the description of the product identifier registry entry
   */
  public String getDescription()
  {
    return description;
  }

  @Override
  public int hashCode()
  {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((className == null) ? 0 : className.hashCode());
    return result;
  }

  @Override
  public boolean equals(Object obj)
  {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (!(obj instanceof ProductIDRegistryEntry))
      return false;
    ProductIDRegistryEntry other = (ProductIDRegistryEntry) obj;
    if (className == null)
    {
      if (other.className != null)
        return false;
    }
    else if (!className.equals(other.className))
      return false;
    return true;
  }

  @Override
  public String toString()
  {
    StringBuilder builder = new StringBuilder();
    builder.append("ProductIDRegistryEntry [name=");
    builder.append(name);
    builder.append(", className=");
    builder.append(className);
    builder.append(", description=");
    builder.append(description);
    builder.append("]");
    return builder.toString();
  }

  @Override
  public int compareTo(ProductIDRegistryEntry o)
  {
    return className.compareTo(o.className);
  }
}
